const fs = require('fs')
const path = require('path')
const render = (res, url) => {
  res.writeHead(200, { "Content-Type": "text/html;charset=utf-8" })
  res.write(fs.readFileSync(path.join(__dirname, url), 'utf8'))
  res.end()
}
const route = {
  '/home': (res) => {
    render(res, './static/home.html')
  },
  '/login': (res) => {
    render(res, './static/login.html')
  },
  '/404': (res) => {
    res.writeHead(404, { "Content-Type": "text/html;charset=utf-8" })
    res.end(fs.readFileSync(path.join(__dirname, './static/404.html'), 'utf8'))
    console.log(path.join(__dirname, './static/404.html'))
  }
}
module.exports = route
